import request from '~/utils/request'
import type { LoginQRCode, SendData, LoginForPhoneData, LoginResult, RegisterData, AccountLoginData } from './types'


class APIAuth {
    /** 二维码 URL 获取 */
    static loginQRCode() {
        return request<LoginQRCode>('/WeChat/loginQRCode', {
            method: 'POST'
        })
    }

    /** 判断用户是否关注公众号并且允许登录 */
    static checkLoginState(scene_str: string) {
        return request<LoginResult>('/WeChat/checkLoginState', {
            method: 'POST',
            body: { scene_str }
        })
    }

    /** 发送验证码 */
    static smsSend(data: SendData) {
        return request<any>('/sms/send', {
            method: 'POST',
            body: data
        })
    }

    /** 手机号登录 */
    static loginForPhone(body: LoginForPhoneData) {
        return request<LoginResult>('/loginForPhone', {
            method: 'POST',
            body
        })
    }

    /** 绑定手机号 */
    static changePhone(data: LoginForPhoneData, headers: any) {
        return request<any>('/changePhone', {
            method: 'POST',
            body: data,
            headers
        })
    }

    /** 手机号注册 */
    static registerForPhone(data: RegisterData) {
        return request<any>('/registerForPhone', {
            method: 'POST',
            body: data
        })
    }

    static accountLogin(data: AccountLoginData) {
        return request<any>('/login', {
            method: 'POST',
            body: data
        })
    }

    /** 获取个人基本信息 */
    static getPersonal() {
        return request<any>('/getPersonal', {
            method: 'POST',
        })
    }

    /** 获取个人信息，已合并关于用户数据接口 */
    static getAllUser() {
        return request<any>('/getAllUser', {
            method: 'POST',
        })
    }

    static passwordReset(data: any) {
        return request<any>('/passwordReset', {
            method: 'POST',
            body: data
        })
    }

}

export default APIAuth